﻿Imports log4net

Public Class Log
    Private Shared _log As ILog
    Public Shared ReadOnly Property LogFormat() As String
        Get
            Return Environment.NewLine + "ErrorCode: {0} " + Environment.NewLine + "Function: {1} " + Environment.NewLine + "Detail: {2} "
        End Get
    End Property

    Public Shared Sub WriteException(ByVal context As Type, ByVal errorCode As String, ByVal ex As Exception)
        _log = LogManager.GetLogger(context)
        _log.[Error](errorCode, ex)
    End Sub

    Public Shared Sub WriteError(ByVal context As Type, ByVal methodName As String, ByVal code As String, ByVal detail As String)
        _log = LogManager.GetLogger(context)
        _log.ErrorFormat(LogFormat, code, methodName, detail)
    End Sub

    Public Shared Sub WriteInfo(ByVal context As Type, ByVal code As String, ByVal methodName As String, ByVal detail As String)
        _log = LogManager.GetLogger(context)
        _log.InfoFormat(LogFormat, code, methodName, detail)
    End Sub
End Class
